import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper_view/flutter_swiper_view.dart';

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<StatefulWidget> createState() {
    return _HomePageState();
  }
}

class _HomePageState extends State<HomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
          child: Column(children: [
        Container(
          height: 150.h,
          width: double.infinity,
          child: Swiper(
              itemCount: 3,
              indicatorLayout: PageIndicatorLayout.COLOR,
              autoplay: true,
              pagination: const SwiperPagination(),
              control: const SwiperControl(),
              itemBuilder: (context, index) {
                return Container(
                  height: 150.h,
                  color: Colors.lightBlue,
                );
              }),
        ),
        Expanded(
            child: ListView.builder(
          itemBuilder: (context, index) {
            return _listItemView();
          },
          itemCount: 10,
        ))
      ])),
    );
  }
}

Widget _listItemView() {
  return Container(
      margin: EdgeInsets.only(top: 5.h, bottom: 5.h, left: 10.h, right: 10.h),
      padding: EdgeInsets.only(top: 5.h, bottom: 5.h, left: 10.h, right: 10.h),
      decoration: BoxDecoration(
          border: Border.all(
            color: Colors.black12,
            width: 0.5.r,
          ),
          borderRadius: BorderRadius.all(Radius.circular(6.r))),
      child: Column(
        children: [
          Row(children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(15.r),
              child: Image.network(
                "https://picx.zhimg.com/v2-d6f44389971daab7e688e5b37046e4e4_720w.jpg",
                width: 30.r,
                height: 30.r,
                fit: BoxFit.fill,
              ),
            ),
            SizedBox(
              width: 5.w,
            ),
            Text("作者", style: TextStyle(color: Colors.black)),
            Expanded(child: SizedBox()),
            Text("2024-12-12 12:19",
                style: TextStyle(color: Colors.black, fontSize: 13.sp)),
            SizedBox(
              width: 5.w,
            ),
            Text(
              "置顶",
              style: TextStyle(color: Colors.blue, fontWeight: FontWeight.w600),
            )
          ]),
          Text(
            "标题标题标题标题标题标题标题标题标题标题标题标题标题",
            style: TextStyle(color: Colors.black, fontSize: 14.sp),
          ),
          Row(
            children: [
              Text("分类",
                  style: TextStyle(color: Colors.green, fontSize: 12.sp)),
              Expanded(child: SizedBox()),
              Image.asset(
                "assets/images/img_collect_grey.png",
                width: 30.r,
                height: 30.r,
              )
            ],
          )
        ],
      ));
}
